(global.webpackJsonp = global.webpackJsonp || []).push([
  ["pages/app_admin/add-goods/add-goods"], {
    "1f69": function (e, t, i) {
      i.r(t);
      var r = i("3e36"),
        o = i.n(r);
      for (var a in r) "default" !== a && function (e) {
        i.d(t, e, function () {
          return r[e]
        })
      }(a);
      t.default = o.a
    },
    "3e36": function (e, t, i) {
      (function (e) {
        function r(e, t) {
          var i = Object.keys(e);
          if (Object.getOwnPropertySymbols) {
            var r = Object.getOwnPropertySymbols(e);
            t && (r = r.filter(function (t) {
              return Object.getOwnPropertyDescriptor(e, t).enumerable
            })), i.push.apply(i, r)
          }
          return i
        }

        function o(e, t, i) {
          return t in e ? Object.defineProperty(e, t, {
            value: i,
            enumerable: !0,
            configurable: !0,
            writable: !0
          }) : e[t] = i, e
        }
        Object.defineProperty(t, "__esModule", {
          value: !0
        }), t.default = void 0;
        var a = {
          data: function () {
            return {
              postageIndex: -1,
              height: 0,
              beSubmit: !1,
              form: {},
              forehead: -1,
              unit: "件",
              iphone_x: !1,
              modal: !1,
              error: !1,
              set_cat: !1,
              set_postage: !1,
              set_service: !1,
              confine: !1,
              is_service: !1,
              goods_card: [],
              img: [],
              cat: [],
              card: [],
              goods_detail: [],
              beMove: !1,
              service: [],
              postage: [],
              beCat: [{
                label: "未选择"
              }],
              isChooseCat: ["未选择"],
              bePostage: "",
              beService: [],
              in_cat: "",
              newIndex: "0",
              index: "0",
              attr: [],
              have_children: !1,
              disabled: !0,
              imgHidden: !0,
              flag: !1,
              x: 0,
              y: 0,
              first_service: !0,
              choose_list: [],
              elements: [],
              img_src: "",
              dialog: !1,
              loading: !1
            }
          },
          computed: function (e) {
            for (var t = 1; t < arguments.length; t++) {
              var i = null != arguments[t] ? arguments[t] : {};
              t % 2 ? r(i, !0).forEach(function (t) {
                o(e, t, i[t])
              }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(i)) : r(i).forEach(function (t) {
                Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(i, t))
              })
            }
            return e
          }({}, (0, i("2f62").mapState)({
            theme: function (e) {
              return e.mallConfig.theme
            },
            userInfo: function (e) {
              return e.user.info
            },
            adminImg: function (e) {
              return e.mallConfig.__wxapp_img.app_admin
            }
          })),
          methods: {
            toSubmit: function () {
              var t = this;
              if (t.loading) return !1;
              e.showLoading({
                title: "提交中..."
              }), t.loading = !0, t.beSubmit = !1, t.$request({
                url: t.$api.app_admin.edit,
                data: {
                  form: JSON.stringify(t.form)
                },
                method: "post"
              }).then(function (i) {
                t.$hideLoading(), e.hideLoading(), t.loading = !1, 0 == i.code && 0 == i.code ? (e.showToast({
                  title: i.msg,
                  duration: 1e3
                }), e.setStorage({
                  key: "goods_status",
                  data: "保存成功"
                }), setTimeout(function () {
                  e.navigateBack()
                }, 500)) : e.showToast({
                  title: i.msg,
                  icon: "none",
                  duration: 1e3
                })
              }).catch(function (i) {
                t.loading = !1, t.$hideLoading(), e.hideLoading()
              })
            },
            save: function () {
              var e = !1,
                t = this,
                i = t.form;
              if (!(t.img.length > 0)) return t.error = "请上传商品图片", !1;
              if (i.pic_url = t.img, !i.name) return t.error = "请设置商品名称", !1;
              if (i.cats = [], "未选择" == t.beCat[0].label) return t.error = "请设置商品分类", !1;
              if (t.beCat.forEach(function (e) {
                  i.cats.push(e.value)
                }), !t.unit) return t.error = "请设置商品单位", !1;
              if (i.unit || (i.unit = t.unit), !i.cost_price) return t.error = "请设置商品成本价", !1;
              if (i.cost_price < 0) return t.error = "成本价不得小于零", !1;
              if (!i.original_price) return t.error = "请设置商品原价", !1;
              if (i.original_price < 0) return t.error = "商品原价不得小于零", !1;
              if (t.attr.length > 0) i.use_attr = 1, i.goods_num = 0, t.attr.forEach(function (i, r) {
                return t.attr[r].attr_list[0].attr_name ? t.attr[r].price ? t.attr[r].stock ? void(r == t.attr.length - 1 && (e = !0)) : (t.error = "请输入规格库存", !1) : (t.error = "请输入规格售价", !1) : (t.error = "请输入规格名", !1)
              }), i.attr = t.attr;
              else {
                if (i.use_attr = 0, i.attr = [], !i.price) return t.error = "请设置商品售价", !1;
                if (!i.goods_num) return t.error = "商品库存不得为空", !1;
                if (i.goods_num < 0) return t.error = "商品库存不得小于零", !1;
                if (i.price < .01) return t.error = "商品售价不得小于零", !1;
                e = !0
              }
              if (i.cards = t.goods_card, i.services = [], t.beService.length > 0 && (i.services = t.beService), i.status = 0, i.virtual_sales = 0, i.cover_pic = "", i.sort = 100, i.accumulative = 1, i.member_price = {}, i.mchCats = [], !(t.goods_detail.length > 0)) return t.error = "请设置图文描述", !1;
              i.detail = "", t.goods_detail.forEach(function (e) {
                console.log(e), i.detail += "<p><img src=" + e.pic_url + "></p>"
              }), i.forehead_integral && (i.forehead_integral > 0 ? i.forehead_integral_type : (i.forehead_integral_type, i.forehead_integral = i.forehead_integral.replace("%", ""))), i.give_integral && (i.give_integral > 0 ? i.give_integral_type : (i.give_integral_type, i.give_integral = i.give_integral.replace("%", ""))), i.freight_id = t.bePostage.id, i.freight = t.bePostage, i.individual_share = 0, i.is_level = 0, i.individual_share = 0, i.video_url = "", e && (t.form = i, t.toSubmit())
            },
            submit: function () {
              var e = !1,
                t = this,
                i = t.form;
              if (!(t.img.length > 0)) return t.error = "请上传商品图片", !1;
              if (i.pic_url = t.img, !i.name) return t.error = "请设置商品名称", !1;
              if (i.cats = [], "未选择" == t.beCat[0].label) return t.error = "请设置商品分类", !1;
              if (t.beCat.forEach(function (e) {
                  i.cats.push(e.value)
                }), !t.unit) return t.error = "请设置商品单位", !1;
              if (i.unit || (i.unit = t.unit), !i.cost_price) return t.error = "请设置商品成本价", !1;
              if (i.cost_price < 0) return t.error = "成本价不得小于零", !1;
              if (!i.original_price) return t.error = "请设置商品原价", !1;
              if (i.original_price < 0) return t.error = "商品原价不得小于零", !1;
              if (t.attr.length > 0) i.use_attr = 1, i.goods_num = 0, t.attr.forEach(function (i, r) {
                return t.attr[r].attr_list[0].attr_name ? t.attr[r].price ? t.attr[r].stock ? void(r == t.attr.length - 1 && (e = !0)) : (t.error = "请输入规格库存", !1) : (t.error = "请输入规格售价", !1) : (t.error = "请输入规格名", !1)
              }), i.attr = t.attr;
              else {
                if (i.use_attr = 0, i.attr = [], !i.price) return t.error = "请设置商品售价", !1;
                if (!i.goods_num) return t.error = "商品库存不得为空", !1;
                if (i.goods_num < 0) return t.error = "商品库存不得小于零", !1;
                if (i.price < .01) return t.error = "商品售价不得小于零", !1;
                e = !0
              }
              if (i.cards = t.goods_card, i.services = [], t.beService.length > 0 && (i.services = t.beService), i.status = 1, i.virtual_sales = 0, i.cover_pic = "", i.sort = 100, i.accumulative = 1, i.member_price = {}, i.mchCats = [], !(t.goods_detail.length > 0)) return t.error = "请设置图文描述", !1;
              i.detail = "", t.goods_detail.forEach(function (e) {
                console.log(e), i.detail += "<p><img src=" + e.pic_url + "></p>"
              }), i.forehead_integral && (i.forehead_integral > 0 ? i.forehead_integral_type : (i.forehead_integral_type, i.forehead_integral = i.forehead_integral.replace("%", ""))), i.give_integral && (i.give_integral > 0 ? i.give_integral_type : (i.give_integral_type, i.give_integral = i.give_integral.replace("%", ""))), i.freight_id = t.bePostage.id, i.freight = t.bePostage, i.individual_share = 0, i.is_level = 0, i.individual_share = 0, i.video_url = "", e && (t.form = i, t.beSubmit = !0)
            },
            close: function () {
              this.error = null, this.modal = !1
            },
            inputAttr: function (e) {
              this.attr[e].attr_list[0].attr_id = (+e + 2).toString()
            },
            _longtap: function (t, i, r) {
              var o = this;
              e.createSelectorQuery().selectAll(".move-img").fields({
                dataset: !0,
                rect: !0
              }, function (e) {
                o.elements = e
              }).exec(), r.detail, o.img[i].pic_url = "", o.x = r.currentTarget.offsetLeft, o.y = r.currentTarget.offsetTop, o.imgHidden = !1, o.flag = !0, o.beMove = !0, o.img_src = t, o.beginIndex = i
            },
            touchend: function (e) {
              var t = this;
              if (t.flag) {
                for (var i = e.changedTouches[0].pageX, r = e.changedTouches[0].pageY, o = t.elements, a = t.img, n = t.beginIndex, s = 0; s < o.length; s++) {
                  var c = o[s];
                  if (i > c.left && i < c.right && r > c.top && r < c.bottom) {
                    var d = c.dataset.index;
                    if (n < d) {
                      for (var l = a[n], u = n; u < d; u++) a[u] = a[u + 1];
                      a[d] = l
                    }
                    if (n > d) {
                      for (var g = a[n], f = n; f > d; f--) a[f] = a[f - 1];
                      a[d] = g
                    }
                    a[d].pic_url = t.img_src, t.img = a
                  }
                }
                t.img[n].pic_url || (t.img[n].pic_url = t.img_src), t.imgHidden = !0, t.flag = !1, t.beMove = !1, t.beginIndex = null
              }
            },
            touchm: function (e) {
              if (this.flag) {
                var t = e.touches[0].pageX,
                  i = e.touches[0].pageY;
                this.x = t - 60, this.y = i - 129
              }
            },
            cancelService: function () {
              var e = this.beService,
                t = this.service;
              e.length > 0 ? t.forEach(function (t, i) {
                t.isChoose = !1, e.forEach(function (e) {
                  e.id == t.id && (t.isChoose = !0)
                })
              }) : t.forEach(function (e, t) {
                e.isChoose = !1
              }), this.beService = e, this.service = t, this.set_service = !1, this.is_service = !1
            },
            submitService: function () {
              var e = [];
              this.service.forEach(function (t) {
                t.isChoose && e.push(t)
              }), this.beService = e, this.set_service = !1, this.is_service = !1
            },
            choose: function (e) {
              var t = this;
              t.service.forEach(function (i) {
                console.log(i.id, e.id), i.id == e.id && (i.isChoose = !i.isChoose, t.$forceUpdate())
              })
            },
            toGoodsDetail: function () {
              e.navigateTo({
                url: "/pages/app_admin/goods-detail/goods-detail"
              })
            },
            addImg: function () {
              var t = this,
                i = 9 - t.img.length;
              e.chooseImage({
                count: i,
                sizeType: ["original", "compressed"],
                sourceType: ["album", "camera"],
                success: function (i) {
                  console.log(i);
                  var r = i.tempFilePaths,
                    o = t.img;
                  r.forEach(function (i, a) {
                    e.showLoading({
                      title: "上传中..."
                    });
                    e.uploadFile({
                      url: t.$api.upload.file,
                      filePath: i,
                      name: "file",
                      fileType: "image",
                      formData: {
                        file: i,
                        file_name: ""
                      },
                      success: function (i) {
                        var n = JSON.parse(i.data),
                          s = {
                            pic_url: n.data.url,
                            id: n.data.id
                          };
                        0 == n.code && o.push(s), t.img = o, a == r.length - 1 && e.hideLoading()
                      },
                      fail: function (t) {
                        console.log("upload fail:", t), t && t.errMsg && e.showModal({
                          title: "错误",
                          content: t.errMsg,
                          showCancel: !1
                        })
                      }
                    })
                  })
                }
              })
            },
            del_img: function (e) {
              this.img.splice(e, 1)
            },
            chooseCat: function () {
              this.set_cat = !0, 0 == this.cat.length ? this.modal = !0 : (this.dialog = !0, this.in_cat = null, this.index = 0, this.have_children = !1, this.beCat = [{
                label: "未选择"
              }], this.isChooseCat = ["未选择"], this.choose_list = this.cat, this.$forceUpdate())
            },
            bindChange: function (e) {
              this.newIndex = e.detail.value[0]
            },
            choose_cat: function () {
              var e = this,
                t = e.beCat,
                i = !1,
                r = e.cat[e.newIndex],
                o = e.index;
              if (e.have_children && (r = t[o - 1].children[e.newIndex - 1]), t[o] = r, o++, r) {
                var a, n = [];
                t.forEach(function (e, t) {
                  n.push(e.label)
                }), n.push("未选择"), e.isChooseCat = n, r.children ? (e.choose_list = [{
                  label: "不选择"
                }], setTimeout(function () {
                  r.children.forEach(function (t) {
                    e.choose_list.push(t)
                  })
                }, 0), i = !0) : (t.forEach(function (e, t) {
                  e.label.length > 5 && (e.label = e.label.slice(0, 4) + "..."), 0 == t ? a = e.label : a += "/" + e.label
                }), e.in_cat = a, e.dialog = !1, e.set_cat = !1)
              } else {
                var s;
                t.pop(), t.forEach(function (e, t) {
                  0 == t ? s = e.label : s += "/" + e.label
                }), e.in_cat = s, e.dialog = !1, e.set_cat = !1
              }
              e.newIndex = "0", e.beCat = t, e.index = o, e.have_children = i
            },
            toggle: function (e) {
              this.choose_list = [], this.dialog = !1, this.set_cat = !1, 1 == e ? this.set_postage && (console.log(this.postage, this.newIndex), this.bePostage = this.postage[this.newIndex]) : this.set_postage = !1
            },
            add_attr: function () {
              var e = {
                attr_list: [{
                  attr_group_id: "1",
                  attr_group_name: "规格",
                  attr_id: 0,
                  attr_name: ""
                }],
                stock: "",
                price: "",
                no: "",
                weight: "",
                pic_url: "",
                share_commission_first: 0,
                share_commission_second: 0,
                share_commission_third: 0,
                member_price: {}
              };
              this.attr.push(e)
            },
            pop: function (e) {
              this.attr.splice(e, 1)
            },
            chooseService: function () {
              var t = this;
              t.first_service ? t.$request({
                url: t.$api.app_admin.service
              }).then(function (i) {
                if (t.$hideLoading(), 0 == i.code) {
                  t.service = i.data.list, 0 == i.data.list.length ? t.modal = !0 : t.is_service = !0;
                  var r = [];
                  i.data.list.forEach(function (e) {
                    e.isChoose = !1, 1 == e.is_default && (r.push(e), e.isChoose = !0)
                  }), t.set_service = !0, t.beService = r, t.first_service = !1
                } else e.showToast({
                  title: i.msg,
                  icon: "none",
                  duration: 1e3
                })
              }).catch(function (e) {
                t.$hideLoading()
              }) : 0 == t.service.length ? t.modal = !0 : t.is_service = !0
            },
            chooseCard: function () {
              var t = this;
              t.$request({
                url: t.$api.app_admin.card
              }).then(function (i) {
                t.$hideLoading(), 0 == i.code ? (t.card = i.data.list, 0 == i.data.list.length ? (t.set_card = !0, t.modal = !0) : e.navigateTo({
                  url: "/pages/app_admin/goods-card/goods-card"
                })) : e.showToast({
                  title: i.msg,
                  icon: "none",
                  duration: 1e3
                })
              }).catch(function (e) {
                t.$hideLoading()
              })
            },
            chooseExpress: function () {
              var t = this;
              t.$request({
                url: t.$api.app_admin.postage
              }).then(function (i) {
                if (t.$hideLoading(), 0 == i.code)
                  if (0 == i.data.list.length) t.set_postage = !0, t.modal = !0, t.postage = i.data.list;
                  else {
                    var r = [];
                    i.data.list.forEach(function (e, t) {
                      r.push(i.data.list[t].id)
                    });
                    var o = r.indexOf(t.bePostage.id);
                    o > -1 ? (t.postageIndex = o, t.newIndex = o) : t.bePostage = "", t.set_postage = !0, t.dialog = !0, t.postage = i.data.list
                  }
                else e.showToast({
                  title: i.msg,
                  icon: "none",
                  duration: 1e3
                })
              }).catch(function (e) {
                t.$hideLoading()
              })
            },
            getCat: function () {
              var t = this;
              t.$request({
                url: t.$api.app_admin.cat
              }).then(function (i) {
                t.$hideLoading(), 0 == i.code ? t.cat = i.data.list : e.showToast({
                  title: i.msg,
                  icon: "none",
                  duration: 1e3
                })
              }).catch(function (e) {
                t.$hideLoading()
              })
            },
            getService: function () {
              var t = this;
              t.$request({
                url: t.$api.app_admin.service
              }).then(function (i) {
                t.$hideLoading(), 0 == i.code ? (t.service = i.data.list, t.beService = [], i.data.list.forEach(function (e) {
                  e.isChoose = !1, 1 == e.is_default && (t.beService.push(e), e.isChoose = !0)
                })) : e.showToast({
                  title: i.msg,
                  icon: "none",
                  duration: 1e3
                })
              }).catch(function (e) {
                t.$hideLoading()
              })
            },
            getPostage: function () {
              var t = this;
              t.$request({
                url: t.$api.app_admin.postage
              }).then(function (i) {
                t.$hideLoading(), 0 == i.code ? (t.postage = i.data.list, t.bePostage = "", i.data.list.forEach(function (e) {
                  1 == e.status && (t.bePostage = e)
                })) : e.showToast({
                  title: i.msg,
                  icon: "none",
                  duration: 1e3
                })
              }).catch(function (e) {
                t.$hideLoading()
              })
            },
            getCard: function () {
              var t = this;
              t.$request({
                url: t.$api.app_admin.card
              }).then(function (i) {
                t.$hideLoading(), 0 == i.code ? t.card = i.data.list : e.showToast({
                  title: i.msg,
                  icon: "none",
                  duration: 1e3
                })
              }).catch(function (e) {
                t.$hideLoading()
              })
            }
          },
          onLoad: function (t) {
            var i = this;
            e.getSystemInfo({
              success: function (e) {
                (e.model.indexOf("iPhone X") > -1 || e.model.indexOf("iPhone 11") > -1 || e.model.indexOf("iPhone11") > -1 || e.model.indexOf("iPhone12") > -1 || e.model.indexOf("Unknown Device") > -1) && (i.iphone_x = !0)
              }
            }), e.getSystemInfo({
              success: function (e) {
                var t = e.windowHeight,
                  r = 750 / e.windowWidth;
                i.height = t * r
              }
            }), i.getCat(), i.getService(), i.getPostage(), i.getCard(), e.removeStorage({
              key: "goods_card",
              success: function (e) {
                i.goods_card = []
              }
            }), e.removeStorage({
              key: "goods_detail",
              success: function (e) {
                i.goods_detail = []
              }
            })
          },
          onShow: function () {
            var t = this;
            e.getStorage({
              key: "goods_card",
              success: function (e) {
                t.goods_card = e.data
              }
            }), e.getStorage({
              key: "goods_detail",
              success: function (e) {
                t.goods_detail = e.data
              }
            })
          }
        };
        t.default = a
      }).call(this, i("543d").default)
    },
    6683: function (e, t, i) {
      i.r(t);
      var r = i("dde8"),
        o = i("1f69");
      for (var a in o) "default" !== a && function (e) {
        i.d(t, e, function () {
          return o[e]
        })
      }(a);
      i("8ff0");
      var n = i("2877"),
        s = Object(n.a)(o.default, r.a, r.b, !1, null, "b4c6c038", null);
      t.default = s.exports
    },
    "675b": function (e, t, i) {},
    "8ff0": function (e, t, i) {
      var r = i("675b");
      i.n(r).a
    },
    dde8: function (e, t, i) {
      var r = function () {
          var e = this;
          e.$createElement;
          e._self._c, e._isMounted || (e.e0 = function (t) {
            e.confine = !e.confine
          })
        },
        o = [];
      i.d(t, "a", function () {
        return r
      }), i.d(t, "b", function () {
        return o
      })
    }
  },
  [
    ["8e27", "common/runtime", "common/vendor"]
  ]
]);